/*
 * Copyright (c) 2010 Vadim Zhukov <persgray@gmail.com>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#ifndef OW_LOGMSG_H
#define OW_LOGMSG_H

struct log_msg_hdr {
	uint64_t	timestamp;
	uint32_t	source_pid;
	uint32_t	repeat;
	uint32_t	flags;
	uint32_t	unused;
};

enum {
	LOG_MSG_ACTION_LOG       = 0x01,
	LOG_MSG_ACTION_ALARM     = 0x02,
	LOG_MSG_ACTION_MASK      = 0x03,
};

enum {
	LOG_MSG_SEVERITY_MASK    = 0xF0,
	LOG_MSG_SEVERITY_DEFAULT = 0x70,
};

struct log_msg {
	struct log_msg		*next;
	struct log_msg_hdr	*hdr;
	char			*producer;
	char			*text;
	char			*source;      /* external reference, optional */
};


struct log_msg		*log_msg_new(struct log_msg *);
void			 log_msg_free(struct log_msg *);
struct peer_task	*log_msg_to_peer_task(struct log_msg *);

#endif /* OW_LOGMSG_H */
